local continuousfire = fk.CreateSkill{
  name = "continuousfire",
}

Fk:loadTranslationTable{
  ["continuousfire"] = "连射",
  [":continuousfire"] = "每个主要阶段开始时，你可以将一张基本牌当【杀】使用，然后废除一个装备栏并摸一张牌。",
  ["RideSlot"] = "坐骑栏",
  ["#continuousfire"] = "连射：将一张基本牌当【杀】使用。",
  ["#continuousfire1"] = "选择废除一个装备栏。",

  ["$continuousfire"] = "四连发！",
}

continuousfire:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and 
      player:hasSkill(continuousfire.name) and
      player.phase >= Player.Judge and player.phase <= Player.Discard and
      not player:isKongcheng() and not target.dead and
      #player:getAvailableEquipSlots() > 0 then
      return true
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local use = room:askToUseVirtualCard(player, {
      name = {"slash"},
      skill_name = continuousfire.name,
      prompt = "#continuousfire",
      cancelable = true,
      extra_data = {
        bypass_times = true,
        extraUse = true,
      },
      card_filter = {
        n = 1,
        pattern = ".|.|.|.|.|basic"
      },
      skip = true,
    })
    if not use then
      return false
    end
    local all_choices = {"WeaponSlot", "ArmorSlot", "DefensiveRideSlot", "OffensiveRideSlot", "TreasureSlot"}
    local subtypes = {Card.SubtypeWeapon, Card.SubtypeArmor, Card.SubtypeDefensiveRide, Card.SubtypeOffensiveRide, Card.SubtypeTreasure}
    local choices = {}
    for i = 1, 5, 1 do
      if #player:getAvailableEquipSlots(subtypes[i]) > 0 then
        table.insert(choices, all_choices[i])
      end
    end
    local choice = player.room:askToChoice(player, {
      choices = choices,
      skill_name = continuousfire.name,
      prompt = "#continuousfire1",
      all_choices = all_choices,
    })
      event:setCostData(self, {extra_data = use, choice = choice})
    return true
  end,

  on_use = function(self, event, target, player, data)
    local room = player.room
    room:useCard(event:getCostData(self).extra_data)
    room:abortPlayerArea(player, {event:getCostData(self).choice})
  end,
})

return continuousfire